package db.ext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.g4studio.common.web.BaseAction;
import org.g4studio.common.web.BaseActionForm;
import org.g4studio.core.json.JsonHelper;
import org.g4studio.core.metatype.Dto;
import org.g4studio.core.metatype.impl.BaseDto;
import org.g4studio.core.mvc.xstruts.action.ActionForm;
import org.g4studio.core.mvc.xstruts.action.ActionForward;
import org.g4studio.core.mvc.xstruts.action.ActionMapping;
import org.g4studio.core.util.G4Utils;
import java.util.*;
import db.imp.Ea_demo_sfxmServiceImp;

/**
 * ea_demo_sfxm
 */
public class Ea_demo_sfxmManage extends BaseAction {

	private Ea_demo_sfxmService ea_demo_sfxmService = ( Ea_demo_sfxmService) super.getService("ea_demo_sfxmService");

	public ActionForward ea_demo_sfxmInit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		return mapping.findForward("ea_demo_sfxmList");
	}
	
	
	/**
	 * 保存实例
	 * 
	 * @param
	 * @return
	 */
	public ActionForward saveEa_demo_sfxmItem(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception 
	{
		BaseActionForm aForm = (BaseActionForm) form;
		Dto inDto = aForm.getParamAsDto(request);
		inDto.put("jointime", G4Utils.getCurDate());
		Dto outDto = ea_demo_sfxmService.saveEa_demo_sfxmItem(inDto);
		String jsonString = JsonHelper.encodeObject2Json(outDto);
		write(jsonString, response);
		return mapping.findForward(null);
	}

	/**
	 * 删除实例
	 * 
	 * @param
	 * @return
	 */
	public ActionForward deleteEa_demo_sfxmItems(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String strChecked = request.getParameter("strChecked");
		Dto inDto = new BaseDto();
		
		inDto.put("XMID", strChecked);
	
		ea_demo_sfxmService.deleteEa_demo_sfxmItems(inDto);
		setOkTipMsg("订单数据删除成功", response);
		return mapping.findForward(null);
	}

	/**
	 * 修改订单
	 * 
	 * @param
	 * @return
	 */
	public ActionForward updateEa_demo_sfxmItem(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		BaseActionForm aForm = (BaseActionForm) form;
		Dto inDto = aForm.getParamAsDto(request);
		ea_demo_sfxmService.updateEa_demo_sfxmItem(inDto);
		setOkTipMsg("订单数据修改成功", response);
		return mapping.findForward(null);
	}
	
	
	public ActionForward queryEa_demo_sfxmForManage(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		BaseActionForm aForm = (BaseActionForm)form;
		Dto dto = aForm.getParamAsDto(request);
		List userList = g4Reader.queryForPage("Ea_demo_sfxm.queryEa_demo_sfxmForManage", dto);
		Integer pageCount = (Integer) g4Reader.queryForObject("Order.queryEa_demo_sfxmForManageForPageCount", dto);
		String jsonString = JsonHelper.encodeList2PageJson(userList, pageCount, null);
		write(jsonString, response);
		return mapping.findForward(null);
	}
	
	
}